﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common
{
    public class NullableHelper
    {
        /*
        public static T Cast<T>( Nullable<T> n, T defaultValue )
        {
            if (n.HasValue)
            {
                return n.Value;
            }
            else
            {
                return defaultValue;
            }
        }*/

        public static T CastValueType<T>( Nullable<T> n ) where T : struct
        {
            if (n.HasValue)
            {
                return n.Value;
            }
            else
            {
                return default( T );
            }
        }
    }
}
